package com.kou.backend.controller.log;

import com.github.pagehelper.PageInfo;
import com.kou.backend.api.log.ILogLoginClient;
import com.kou.backend.request.log.ExportLogReqDTO;
import com.kou.backend.request.log.LogLoginQueryListReqDTO;
import com.kou.backend.resposne.ResultResponse;
import com.kou.backend.resposne.log.LogLoginListResponseDTO;
import com.kou.backend.service.UserLoginLogService;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RestController;

import jakarta.servlet.http.HttpServletResponse;

/**
 * @author: Kou
 * @since: 2023/9/2 13:44
 */
@RestController
public class LogLoginController implements ILogLoginClient {
    @Resource
    private UserLoginLogService userLoginLogService;

    @Override
    public ResultResponse<PageInfo<LogLoginListResponseDTO>> queryList(LogLoginQueryListReqDTO logLoginQueryListReqDTO) {
        PageInfo<LogLoginListResponseDTO> responseDTO = userLoginLogService.queryList(logLoginQueryListReqDTO);
        return ResultResponse.success(responseDTO);
    }

    @Override
    @PreAuthorize("hasAnyAuthority('all')")
    public void export(ExportLogReqDTO exportLogReqDTO, HttpServletResponse httpServletResponse) {
        userLoginLogService.export(exportLogReqDTO,httpServletResponse);
    }
}
